import 'dart:convert';

/// id : "aaa25f8c-b538-42c7-88ea-8c55a061ccae"
/// message : {"id":"aaa25f8c-b538-42c7-88ea-8c55a061ccae","author":{"role":"user"},"create_time":1687000245.091979,"content":{"content_type":"text","parts":["flutter插件的ios部分怎么写"]},"status":"finished_successfully","weight":1,"metadata":{"timestamp_":"absolute"},"recipient":"all"}
/// parent : "c48c92cd-18d9-4e50-ad2d-863cc2a34b09"
/// children : ["d3148c1f-ec5b-455b-ae90-8b60dea1ca57"]

MappingBean mappingBeanFromJson(String str) =>
    MappingBean.fromJson(json.decode(str));
String mappingBeanToJson(MappingBean data) => json.encode(data.toJson());

class MappingBean {
  MappingBean({
    String? id,
    String? uuid,
    Message? message,
    String? parent,
    List<String>? children,
  }) {
    _id = id;
    _uuid = uuid;
    _message = message;
    _parent = parent;
    _children = children;
  }

  MappingBean.fromJson(dynamic json) {
    _id = json['id'];
    _uuid = json['uuid'];
    _message =
        json['message'] != null ? Message.fromJson(json['message']) : null;
    _parent = json['parent'];
    _children = json['children'] != null ? json['children'].cast<String>() : [];
  }
  String? _uuid;
  String? _id;
  Message? _message;
  String? _parent;
  List<String>? _children;
  MappingBean copyWith({
    String? uuid,
    String? id,
    Message? message,
    String? parent,
    List<String>? children,
  }) =>
      MappingBean(
        uuid: uuid ?? _uuid,
        id: id ?? _id,
        message: message ?? _message,
        parent: parent ?? _parent,
        children: children ?? _children,
      );
  String? get uuid => _uuid;
  set uuid(v) => _uuid = v;
  String? get id => _id;
  Message? get message => _message;
  String? get parent => _parent;
  List<String>? get children => _children;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['uuid'] = _uuid;
    map['id'] = _id;
    if (_message != null) {
      map['message'] = _message?.toJson();
    }
    map['parent'] = _parent;
    map['children'] = _children;
    return map;
  }
}

/// id : "aaa25f8c-b538-42c7-88ea-8c55a061ccae"
/// author : {"role":"user"}
/// create_time : 1687000245.091979
/// content : {"content_type":"text","parts":["flutter插件的ios部分怎么写"]}
/// status : "finished_successfully"
/// weight : 1
/// metadata : {"timestamp_":"absolute"}
/// recipient : "all"

Message messageFromJson(String str) => Message.fromJson(json.decode(str));
String messageToJson(Message data) => json.encode(data.toJson());

class Message {
  Message({
    String? id,
    Author? author,
    num? createTime,
    Content? content,
    String? status,
    num? weight,
    Metadata? metadata,
    String? recipient,
  }) {
    _id = id;
    _author = author;
    _createTime = createTime;
    _content = content;
    _status = status;
    _weight = weight;
    _metadata = metadata;
    _recipient = recipient;
  }

  Message.fromJson(dynamic json) {
    _id = json['id'];
    _author = json['author'] != null ? Author.fromJson(json['author']) : null;
    _createTime = json['create_time'];
    _content =
        json['content'] != null ? Content.fromJson(json['content']) : null;
    _status = json['status'];
    _weight = json['weight'];
    _metadata =
        json['metadata'] != null ? Metadata.fromJson(json['metadata']) : null;
    _recipient = json['recipient'];
  }
  String? _id;
  Author? _author;
  num? _createTime;
  Content? _content;
  String? _status;
  num? _weight;
  Metadata? _metadata;
  String? _recipient;
  Message copyWith({
    String? id,
    Author? author,
    num? createTime,
    Content? content,
    String? status,
    num? weight,
    Metadata? metadata,
    String? recipient,
  }) =>
      Message(
        id: id ?? _id,
        author: author ?? _author,
        createTime: createTime ?? _createTime,
        content: content ?? _content,
        status: status ?? _status,
        weight: weight ?? _weight,
        metadata: metadata ?? _metadata,
        recipient: recipient ?? _recipient,
      );
  String? get id => _id;
  Author? get author => _author;
  num? get createTime => _createTime;
  Content? get content => _content;
  String? get status => _status;
  num? get weight => _weight;
  Metadata? get metadata => _metadata;
  String? get recipient => _recipient;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = _id;
    if (_author != null) {
      map['author'] = _author?.toJson();
    }
    map['create_time'] = _createTime;
    if (_content != null) {
      map['content'] = _content?.toJson();
    }
    map['status'] = _status;
    map['weight'] = _weight;
    if (_metadata != null) {
      map['metadata'] = _metadata?.toJson();
    }
    map['recipient'] = _recipient;
    return map;
  }
}

/// timestamp_ : "absolute"

Metadata metadataFromJson(String str) => Metadata.fromJson(json.decode(str));
String metadataToJson(Metadata data) => json.encode(data.toJson());

class Metadata {
  Metadata({
    String? timestamp,
  }) {
    _timestamp = timestamp;
  }

  Metadata.fromJson(dynamic json) {
    _timestamp = json['timestamp_'];
  }
  String? _timestamp;
  Metadata copyWith({
    String? timestamp,
  }) =>
      Metadata(
        timestamp: timestamp ?? _timestamp,
      );
  String? get timestamp => _timestamp;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['timestamp_'] = _timestamp;
    return map;
  }
}

/// content_type : "text"
/// parts : ["flutter插件的ios部分怎么写"]

Content contentFromJson(String str) => Content.fromJson(json.decode(str));
String contentToJson(Content data) => json.encode(data.toJson());

class Content {
  Content({
    String? contentType,
    List<String>? parts,
  }) {
    _contentType = contentType;
    _parts = parts;
  }

  Content.fromJson(dynamic json) {
    _contentType = json['content_type'];
    _parts = json['parts'] != null ? json['parts'].cast<String>() : [];
  }
  String? _contentType;
  List<String>? _parts;
  Content copyWith({
    String? contentType,
    List<String>? parts,
  }) =>
      Content(
        contentType: contentType ?? _contentType,
        parts: parts ?? _parts,
      );
  String? get contentType => _contentType;
  List<String>? get parts => _parts;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['content_type'] = _contentType;
    map['parts'] = _parts;
    return map;
  }
}

/// role : "user"

Author authorFromJson(String str) => Author.fromJson(json.decode(str));
String authorToJson(Author data) => json.encode(data.toJson());

class Author {
  Author({
    String? role,
  }) {
    _role = role;
  }

  Author.fromJson(dynamic json) {
    _role = json['role'];
  }
  String? _role;
  Author copyWith({
    String? role,
  }) =>
      Author(
        role: role ?? _role,
      );
  String? get role => _role;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['role'] = _role;
    return map;
  }
}
